
class P785_39643 {

	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString());
    }

	public static void main(String[] args) {
		
		String line = readLn();
		
		while (line != null) {
			process(line);
			line = readLn();
		}
		
	}

	private static void process(String line) {
		
		char[][] grid = new char[35][85]; 
		boolean[][] filled = new boolean[35][85];
		
		int k_length = 0;
		
		while (!line.startsWith("_")) {
//			System.out.println(">> " + line + " " + line.length());
			
			for (int j = 0; j < line.length(); j++) {
				grid[k_length][j] = line.charAt(j);
			}
			
			k_length++;
			line = readLn();
		}
		
//		print(grid, k_length);
		
		for (int k = 0; k < k_length; k++) {
			for (int j = 0; j < 85; j++) {
				char c = grid[k][j];
				if (c != 0 &&  c != 'X' && c != ' ' && !filled[k][j]) {
//					System.out.println("> " + c);
					flood(c, grid, k, j, filled);
				}
					
			}
		}
		
		print(grid, k_length);
		
		System.out.println(line);
		
	}

	static void print(char[][] grid, int k_length) {
		StringBuffer sb = new StringBuffer();
		
		for (int k = 0; k < k_length; k++) {
			sb = new StringBuffer();
			for (int j = 0; j < 85; j++) {
				if (grid[k][j] == 0) break;
				sb.append(grid[k][j]);
			}
			System.out.println(sb);
		}
		
		
	}
	
	private static void flood(char t, char[][] grid, int k, int j, boolean[][] filled) {
		char c = grid[k][j];
		if (c == 'X') return;
		
		grid[k][j] = t;
		filled[k][j] = true;
	 
		if (k + 1 < grid.length) {
			if (grid[k+1][j] == ' ')
				flood(t, grid, k+1, j, filled);
		}
		if (j + 1 < grid[k].length) {
			if (grid[k][j+1] == ' ')
				flood(t, grid, k, j+1, filled);
		}
		
		if (k - 1 >= 0) {
			if (grid[k-1][j] == ' ')
				flood(t, grid, k-1, j, filled);
		}
		if (j - 1 >= 0) {
			if (grid[k][j-1] == ' ')
				flood(t, grid, k, j-1, filled);
		}
			
//			if (k + 1 < n && j + 1 < m) value += flood(t, grid, k+1, j+1, n, m);
//			if (k - 1 >= 0 && j - 1 >= 0) value += flood(t, grid, k-1, j-1, n, m);
//			
//			if (k + 1 < n && j - 1 >= 0) value += flood(t, grid, k+1, j-1, n, m);
//			if (k - 1 >= 0 && j + 1 < m) value += flood(t, grid, k-1, j+1, n, m);
	}

	
	
}
